package com.rsk.service.impl;

import com.rsk.dao.SysCompanyContactsRepository;
import com.rsk.entity.SysCompanyContacts;
import com.rsk.service.SysCompanyContactsService;
import com.rsk.utils.algorithm.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

public class SysCompanyContactsServiceImpl implements SysCompanyContactsService {

    @Autowired
    private SysCompanyContactsRepository sysCompanyContactsRepository;

    //新增联系人
    @Transactional
    @Override
    public int saveSysCompanyContacts(Long id, Long companyId, String contactsName, String contactsPhone, String contactsPost, String remarks, Long operatorUser,Integer mainResponsiable) {

        SysCompanyContacts companyContacts = new SysCompanyContacts();
        companyContacts.setId(SnowflakeIdWorker.generateId(true));
        companyContacts.setCompanyId(companyId);
        companyContacts.setContactsName(contactsName);
        companyContacts.setContactsPhone(contactsPhone);
        companyContacts.setContactsPost(contactsPost);
        companyContacts.setRemarks(remarks);
        companyContacts.setOperatorUser(operatorUser);
        sysCompanyContactsRepository.saveAndFlush(companyContacts);
        return 1;
    }

    //删除联系人
    @Transactional
    @Override
    public int delSysCompanyContacts(Long id, Long operatorUser) {
        return sysCompanyContactsRepository.delSysCompanyContacts(id,operatorUser);
    }

    //修改联系人
    @Transactional
    @Override
    public int updateSysCompanyContacts(Long id, Long companyId, String contactsName, String contactsPhone, String contactsPost, String remarks, Long operatorUser,Integer mainResponsiable) {
        return sysCompanyContactsRepository.updateSysCompanyContacts(id,companyId,contactsName,contactsPhone,contactsPost,remarks,operatorUser,mainResponsiable);
    }

}
